package com.qifn.blog.Service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qifn.blog.Dao.TypeDao;
import com.qifn.blog.Model.Type;
import com.qifn.blog.Service.TypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TypeServiceImpl implements TypeService {

    @Resource
    TypeDao typeDao;

    @Override
    public List<Type> queryAdminIndexAllType() {
        return typeDao.queryAdminIndexAllType();
    }

    @Override
    public PageInfo<Type> queryAdminAllType(Integer pageSize,Integer pageNum) {
        PageHelper.startPage(pageNum,pageSize);
        List<Type> typeList = typeDao.queryAdminAllType();
        PageInfo<Type> typePageInfo = new PageInfo<>(typeList);
        return typePageInfo;
    }

    @Override
    public boolean insertType(Type type) {
        Integer one = typeDao.insertType(type);
        if(one > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean deleteTypeById(Integer typeId) {
        Integer one = typeDao.deleteTypeById(typeId);
        if(one > 0){
            return true;
        }else {
            return false;
        }
    }
}
